{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 05.衡量回归算法的标准"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from sklearn import datasets"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 波士顿房产数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "boston = datasets.load_boston()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Boston House Prices dataset\n",
      "===========================\n",
      "\n",
      "Notes\n",
      "------\n",
      "Data Set Characteristics:  \n",
      "\n",
      "    :Number of Instances: 506 \n",
      "\n",
      "    :Number of Attributes: 13 numeric/categorical predictive\n",
      "    \n",
      "    :Median Value (attribute 14) is usually the target\n",
      "\n",
      "    :Attribute Information (in order):\n",
      "        - CRIM     per capita crime rate by town\n",
      "        - ZN       proportion of residential land zoned for lots over 25,000 sq.ft.\n",
      "        - INDUS    proportion of non-retail business acres per town\n",
      "        - CHAS     Charles River dummy variable (= 1 if tract bounds river; 0 otherwise)\n",
      "        - NOX      nitric oxides concentration (parts per 10 million)\n",
      "        - RM       average number of rooms per dwelling\n",
      "        - AGE      proportion of owner-occupied units built prior to 1940\n",
      "        - DIS      weighted distances to five Boston employment centres\n",
      "        - RAD      index of accessibility to radial highways\n",
      "        - TAX      full-value property-tax rate per $10,000\n",
      "        - PTRATIO  pupil-teacher ratio by town\n",
      "        - B        1000(Bk - 0.63)^2 where Bk is the proportion of blacks by town\n",
      "        - LSTAT    % lower status of the population\n",
      "        - MEDV     Median value of owner-occupied homes in $1000's\n",
      "\n",
      "    :Missing Attribute Values: None\n",
      "\n",
      "    :Creator: Harrison, D. and Rubinfeld, D.L.\n",
      "\n",
      "This is a copy of UCI ML housing dataset.\n",
      "http://archive.ics.uci.edu/ml/datasets/Housing\n",
      "\n",
      "\n",
      "This dataset was taken from the StatLib library which is maintained at Carnegie Mellon University.\n",
      "\n",
      "The Boston house-price data of Harrison, D. and Rubinfeld, D.L. 'Hedonic\n",
      "prices and the demand for clean air', J. Environ. Economics & Management,\n",
      "vol.5, 81-102, 1978.   Used in Belsley, Kuh & Welsch, 'Regression diagnostics\n",
      "...', Wiley, 1980.   N.B. Various transformations are used in the table on\n",
      "pages 244-261 of the latter.\n",
      "\n",
      "The Boston house-price data has been used in many machine learning papers that address regression\n",
      "problems.   \n",
      "     \n",
      "**References**\n",
      "\n",
      "   - Belsley, Kuh & Welsch, 'Regression diagnostics: Identifying Influential Data and Sources of Collinearity', Wiley, 1980. 244-261.\n",
      "   - Quinlan,R. (1993). Combining Instance-Based and Model-Based Learning. In Proceedings on the Tenth International Conference of Machine Learning, 236-243, University of Massachusetts, Amherst. Morgan Kaufmann.\n",
      "   - many more! (see http://archive.ics.uci.edu/ml/datasets/Housing)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(boston.DESCR)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['CRIM', 'ZN', 'INDUS', 'CHAS', 'NOX', 'RM', 'AGE', 'DIS', 'RAD',\n",
       "       'TAX', 'PTRATIO', 'B', 'LSTAT'], \n",
       "      dtype='<U7')"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "boston.feature_names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "x = boston.data[:, 5] # 只取第5列的房屋数目的数据作为训练和测试数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(506,)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x.shape # 506行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y = boston.target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(506,)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnX+QHOWZ37/PjhqYJbZHsjcqMUYWd0lJOVmWNmxsEi6u\nCHLW+TCwxQ9hyk6RlCvkD1diKNee1ylipBQJSjaOuT9SqaLs5EiBOQmw18Kqs3xnlKSOCnKtvNJx\nG6Qkd0jgQcDaaLGRBml298kfM73q7ekfb/d0T/+Y76dKtavZ6X7f7t35vm8/7/d9HlFVEEIIKT5D\nWXeAEEJIMlDQCSGkJFDQCSGkJFDQCSGkJFDQCSGkJFDQCSGkJFDQCSGkJFDQCSGkJFDQCSGkJKzp\nZ2Mf+chHdNOmTf1skhBCCs+xY8d+oaojYe/rq6Bv2rQJMzMz/WySEEIKj4icMXkfQy6EEFISKOiE\nEFISKOiEEFISKOiEEFISKOiEEFISjFwuInIawK8BLAFYVNUxEVkHYD+ATQBOA9itqufS6SZJgunZ\nBqYOn8IbC01cU6tiYtdmjI/Ws+5WbJK+nn7enyTb6vfvNan27PM0FpqoiGBJdeVrrWqhtbSM85eW\nAAC1qoU9t23F+Gi9p/bdx+7cMoIjJ+cT/Rva+/wczl1odfW7H4hJxaKOoI+p6i8cr/17AO+o6j4R\nmQSwVlW/FnSesbExpW0xG6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O\n9IGdqlp2L+8fAPiRqt4lIlcAGM66Q0mjqqcA7ADaExIADQDfz7RTKSAidQD/AsBvqWpTRA4A+DyA\nP8y0YwkjIh8H8E8BfBLAJQA/EpEfqur/MzmeM/QOIvJRALcA+HbWfSG9IyIfAvBpAN8BAFW9pKoL\n2fYqdW4G8JeqmvfNe3FZA6AqImvQHpzfyLg/afC3ABxV1QuqugjgfwC4w/RgCvplHgPw+wCWs+5I\nH1AAfyoix0Tk/qw7kxLXAZgH8F87YbRvi8jVWXcqZT4P4OmsO5EGqtoA8B8AvAbgLIB3VfXH2fYq\nFf4CwN8XkQ+LyDCA3wNwrenBFHQAIvI5AG+r6rGs+9InfltVdwD4LIAvi8ins+5QCqwB8LcB/GdV\nHQVwHsBktl1Kj05I6TYAz2TdlzQQkbUAbkd7oL4GwNUi8sVse5U8qvoKgH8H4McAfgTgOIAl0+Mp\n6G1uBHCbiJwG8EcAbhKRJ7PtUnp0ZjtQ1bfRjrd+MtsepcLPAfxcVY92/v8s2gJfVj4L4Geq+lbW\nHUmJfwjgVVWdV9UWgO8B+HsZ9ykVVPU7qnq9qn4awDkA/8f0WAo6AFX9uqp+VFU3of3Y+oKqlm70\nBwARuVpEPmB/D+AzaD/mlQpVfRPA6yJiV5i+GcD/zrBLaXMvShpu6fAagBtEZFhEBO3f5ysZ9ykV\nROSvd75uRDt+/l3TY+lyGTzWA/h++zOBNQC+q6o/yrZLqfHPATzVCUf8FYB/knF/UqEzMP8OgH+W\ndV/SQlWPisizAH4GYBHALMq7Y/Q5EfkwgBaAL0dZzOdOUUIIKQkMuRBCSEmgoBNCSEmgoBNCSEmg\noBNCSEmgoBNCSEmgoBNCSEmgoBNCSEmgoBNCSEn4/xYzmCsxYeBBAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x110432438>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(x, y)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "50.0"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.max(y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X+MXNd1H/Dv2eGTOEsrmqW1IcixKCqtQdYMQ269tdUy\nNULKFpPIkhayTFqwC6Ewqv5htJYibLICBJEEVIjF1rUCtAggxG0USFaoX15TJmAqEZUGFSqlpJeM\nzIqsa1uiPPrFWFw50o7I2d3TP2be8s3M+3Hfm/fm/ZjvBxDE3Z0fd2Z3ztw599xzRVVBRET5N5T2\nAIiIKB4M6EREBcGATkRUEAzoREQFwYBORFQQDOhERAXBgE5EVBAM6EREBcGATkRUECv6eWdXXXWV\nbtiwoZ93SUSUe8ePH/97VR0NupxRQBeR1wD8A4BFAAuqOi4iqwEcBLABwGsAdqvqeb/b2bBhA44d\nO2Zyl0RE1CIir5tcLkzKZYeqblPV8dbXUwCeV9VPAni+9TUREaWklxz6LQAeaf37EQATvQ+HiIii\nMg3oCuCvROS4iNzZ+t4aVX2r9e+3AayJfXRERGTMdFH0t1W1JiK/DuAvReS084eqqiLi2oe39QZw\nJwCsX7++p8ESEZE3oxm6qtZa/38XwPcAfAbAOyKyFgBa/3/X47oPq+q4qo6PjgYu0hIRUUSBAV1E\nVonIFfa/AdwA4McADgG4o3WxOwB8P6lBEhElaWa2hu0HjuLaqcPYfuAoZmZraQ8pEpOUyxoA3xMR\n+/LfVdUfisj/BvCEiHwdwOsAdic3TCKiZMzM1nDvM6+g3lgEANTm6rj3mVcAABNj1TSHFlpgQFfV\nnwHY6vL9XwK4PolBEdFgmZmtYfrIGbw5V8e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mMAPgQwle6QktNKKd0M4Mm0x5IEERkB\ncAuab9TrAKwSka+lO6r4qeqrAP4jgOcA/BDACQCLptdnQG/aDuBmEXkNwF8A2Ckij6Y7pOS0ZjtQ\n1XfRzLd+Jt0RJeIXAH6hqi+3vn4KzQBfVL8H4Eeq+k7aA0nI5wH8XFXPqWoDwDMA/kXKY0qEqn5H\nVT+tqp8DcB7A/zW9LgM6AFW9V1U/oaob0PzYelRVC/fuDwAiskpErrD/DeAGND/mFYqqvg3gDRGx\nT5i+HsD/SXFISbsdBU23tJwFcJ2IDIuIoPn7fDXlMSVCRH699f/1aObPv2t6XVa5DJ41AL7XfE1g\nBYDvquoP0x1SYv4dgMda6YifAfjXKY8nEa035i8A+LdpjyUpqvqyiDwF4EcAFgDMorg7Rp8WkY8D\naAD4RpjFfO4UJSIqCKZciIgKggGdiKggGNCJiAqCAZ2IqCAY0ImICoIBnYioIBjQiYgKggGdiKgg\n/j9948rMqi3spgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x110b0cc88>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = x[y < 50.0]\n",
    "y = y[y < 50.0] # 筛选元素,最高值的几个点最好去掉\n",
    "plt.scatter(x, y)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 使用自己写地简单线性回归法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.2,random_state=666)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(392,)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x_train.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(98,)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x_test.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from playML.SimpleLinearRegression import SimpleLinearRegression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "SimpleLinearRegression()"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "regression = SimpleLinearRegression()\n",
    "regression.fit(x_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7.8608543562689555"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "regression.a_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-27.459342806705543"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "regression.b_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXt4VPWd/98f4hQSag3USCGI0a6F1lJIyXpZ7AVvVEWM\noFjsBbf7W9tutfWyXOz6KO62C5bV2t26Vh5bS4tFLGjEsCt0wdqtfaAGAyICrZUgDgh0JVglYEI+\nvz/OnOScmXOby5lzZub9eh4ecr5zLp8zk7zPdz63r6gqCCGElD4DojaAEEJIYaCgE0JImUBBJ4SQ\nMoGCTgghZQIFnRBCygQKOi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//wXQY9llkvlMQzAk8bfBE4A8AtVfSZak0LjJgCPptwRrwH4\n24jtCYXUg/liAF+N2pawUNWNIrICwIsAegC0o3wrRleKyAcBdAP4RjbBfFaKEkJImUCXCyGElAkU\ndEIIKRMo6IQQUiZQ0AkhpEygoBNCSJlAQSeEkDKBgk4IIWUCBZ0QQsqE/w95nUOthntN7gAAAABJ\nRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x110ea5160>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(x_train, y_train)\n",
    "plt.plot(x_train, regression.predict(x_train), color='r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y_predict = regression.predict(x_test)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 下面是准确度计算地指标 MSE、MAE等"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 均方误差MSE(Mean Squared Error)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "24.156602134387438"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse_test = np.sum((y_predict-y_test)**2)/len(y_test)\n",
    "mse_test"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "  ## 均方根误差RMSE(Root Mean Squared Error)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4.914936635846635"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from math import sqrt\n",
    "rmse_test = sqrt(mse_test)\n",
    "rmse_test"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Mean Absolute Error"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.5430974409463873"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mae_test = np.sum(np.absolute(y_predict-y_test))/len(y_test)\n",
    "mae_test # 平均误差"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 调用自己封装的计算误差的方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from playML.metrics import mean_squared_error\n",
    "from playML.metrics import mean_absolute_error\n",
    "from playML.metrics import root_mean_squared_error"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "24.156602134387438"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mean_squared_error(y_test, y_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.5430974409463873"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mean_absolute_error(y_test, y_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4.914936635846635"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "root_mean_squared_error(y_test, y_predict)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## sklearn中的误差计算实现"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.metrics import mean_absolute_error\n",
    "from sklearn.metrics import mean_squared_error"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.5430974409463873"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mean_absolute_error(y_true=y_test, y_pred=y_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "24.156602134387438"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mean_squared_error(y_true=y_test, y_pred =y_predict)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### RMSE要自己实现，不过就是开平方以下，很容易"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4.914936635846635"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sqrt(mean_squared_error(y_true=y_test, y_pred=y_predict))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 06 R方的计算(R Square)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.61293168039373225"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "1 - mean_squared_error(y_test, y_predict)/np.var(y_test)  # 模型的准确度.var 是方差值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function var in module numpy.core.fromnumeric:\n",
      "\n",
      "var(a, axis=None, dtype=None, out=None, ddof=0, keepdims=<class 'numpy._globals._NoValue'>)\n",
      "    Compute the variance along the specified axis.\n",
      "    \n",
      "    Returns the variance of the array elements, a measure of the spread of a\n",
      "    distribution.  The variance is computed for the flattened array by\n",
      "    default, otherwise over the specified axis.\n",
      "    \n",
      "    Parameters\n",
      "    ----------\n",
      "    a : array_like\n",
      "        Array containing numbers whose variance is desired.  If `a` is not an\n",
      "        array, a conversion is attempted.\n",
      "    axis : None or int or tuple of ints, optional\n",
      "        Axis or axes along which the variance is computed.  The default is to\n",
      "        compute the variance of the flattened array.\n",
      "    \n",
      "        .. versionadded:: 1.7.0\n",
      "    \n",
      "        If this is a tuple of ints, a variance is performed over multiple axes,\n",
      "        instead of a single axis or all the axes as before.\n",
      "    dtype : data-type, optional\n",
      "        Type to use in computing the variance.  For arrays of integer type\n",
      "        the default is `float32`; for arrays of float types it is the same as\n",
      "        the array type.\n",
      "    out : ndarray, optional\n",
      "        Alternate output array in which to place the result.  It must have\n",
      "        the same shape as the expected output, but the type is cast if\n",
      "        necessary.\n",
      "    ddof : int, optional\n",
      "        \"Delta Degrees of Freedom\": the divisor used in the calculation is\n",
      "        ``N - ddof``, where ``N`` represents the number of elements. By\n",
      "        default `ddof` is zero.\n",
      "    keepdims : bool, optional\n",
      "        If this is set to True, the axes which are reduced are left\n",
      "        in the result as dimensions with size one. With this option,\n",
      "        the result will broadcast correctly against the input array.\n",
      "    \n",
      "        If the default value is passed, then `keepdims` will not be\n",
      "        passed through to the `var` method of sub-classes of\n",
      "        `ndarray`, however any non-default value will be.  If the\n",
      "        sub-classes `sum` method does not implement `keepdims` any\n",
      "        exceptions will be raised.\n",
      "    \n",
      "    Returns\n",
      "    -------\n",
      "    variance : ndarray, see dtype parameter above\n",
      "        If ``out=None``, returns a new array containing the variance;\n",
      "        otherwise, a reference to the output array is returned.\n",
      "    \n",
      "    See Also\n",
      "    --------\n",
      "    std , mean, nanmean, nanstd, nanvar\n",
      "    numpy.doc.ufuncs : Section \"Output arguments\"\n",
      "    \n",
      "    Notes\n",
      "    -----\n",
      "    The variance is the average of the squared deviations from the mean,\n",
      "    i.e.,  ``var = mean(abs(x - x.mean())**2)``.\n",
      "    \n",
      "    The mean is normally calculated as ``x.sum() / N``, where ``N = len(x)``.\n",
      "    If, however, `ddof` is specified, the divisor ``N - ddof`` is used\n",
      "    instead.  In standard statistical practice, ``ddof=1`` provides an\n",
      "    unbiased estimator of the variance of a hypothetical infinite population.\n",
      "    ``ddof=0`` provides a maximum likelihood estimate of the variance for\n",
      "    normally distributed variables.\n",
      "    \n",
      "    Note that for complex numbers, the absolute value is taken before\n",
      "    squaring, so that the result is always real and nonnegative.\n",
      "    \n",
      "    For floating-point input, the variance is computed using the same\n",
      "    precision the input has.  Depending on the input data, this can cause\n",
      "    the results to be inaccurate, especially for `float32` (see example\n",
      "    below).  Specifying a higher-accuracy accumulator using the ``dtype``\n",
      "    keyword can alleviate this issue.\n",
      "    \n",
      "    Examples\n",
      "    --------\n",
      "    >>> a = np.array([[1, 2], [3, 4]])\n",
      "    >>> np.var(a)\n",
      "    1.25\n",
      "    >>> np.var(a, axis=0)\n",
      "    array([ 1.,  1.])\n",
      "    >>> np.var(a, axis=1)\n",
      "    array([ 0.25,  0.25])\n",
      "    \n",
      "    In single precision, var() can be inaccurate:\n",
      "    \n",
      "    >>> a = np.zeros((2, 512*512), dtype=np.float32)\n",
      "    >>> a[0, :] = 1.0\n",
      "    >>> a[1, :] = 0.1\n",
      "    >>> np.var(a)\n",
      "    0.20250003\n",
      "    \n",
      "    Computing the variance in float64 is more accurate:\n",
      "    \n",
      "    >>> np.var(a, dtype=np.float64)\n",
      "    0.20249999932944759\n",
      "    >>> ((1-0.55)**2 + (0.1-0.55)**2)/2\n",
      "    0.2025\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(np.var)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 自定义实现R方计算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.61293168039373225"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from playML.metrics import r2_score\n",
    "r2_score(y_test, y_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
